package com.copa.l2347;

import java.util.HashMap;
import java.util.Map;

/**
 * @author copa
 * @createDate 2023-02-20 09:09
 * @function 二次遍历+哈希表法
 */
public class Test1 {

    public String bestHand(int[] ranks, char[] suits) {
        boolean flag = true;
        for (int i = 0; i < suits.length - 1; i++) {
            if (suits[i] != suits[i + 1]) {
                flag = false;
                break;
            }
        }
        if (flag) {
            return "Flush";
        }
        Map<Integer, Integer> map = new HashMap<>(5, 1.1f);
        for (int rank : ranks) {
            map.put(rank, map.getOrDefault(rank, 0) + 1);
            if (map.get(rank) >= 3) {
                return "Three of a Kind";
            }
        }
        if (map.size() >= 5) {
            return "High Card";
        }
        return "Pair";
    }

    public static void main(String[] args) {
        int[] ranks = {4,4,2,4,4};
        char[] suits = {'d','a','a','b','c'};
        System.out.println(new Test1().bestHand(ranks, suits));
    }
}
